from django.db import models
from imagekit.models import ImageModel

# Create your models here.
class Park(models.Model):
    code=models.CharField(max_length=4)
    name=models.CharField(max_length=300, blank=True,null=True)
    website=models.URLField(blank=True,null=True)
    def __unicode__(self):
        for nm in (self.name, self.code):
            if nm:
                return nm

class Polygon(models.Model):
    new_id = models.CharField(max_length=5)
    park = models.ForeignKey(Park)
    veg_notes = models.TextField(blank=True,null=True)
    soil_notes = models.TextField(blank=True,null=True)

    def __unicode__(self):
        return self.new_id
        
    class Meta:
        unique_together = ("new_id", "park")
        
class Photo(ImageModel):
    DIRECTIONS=(('N','North'),('E','East'),('S','South'),('W','West'))
    
    polygon = models.ForeignKey(Polygon)
    direction = models.CharField(choices=DIRECTIONS, max_length=1)
    original_image = models.ImageField(upload_to='photos')
    
    class IKOptions:
        # This inner class is where we define the ImageKit options for the model
        spec_module = 'imageKitSpecs'
        cache_dir = 'thumbnails'
        image_field = 'original_image'

